<template>
  <div class="music">
    <h1>Music</h1>
    <ul v-if="artists.length > 0">
      <li
        v-for="item of artists"
        :key="item.id"
      >
        <router-link :to="{ name: 'SingerDetail', params: { id: item.id ,name:item.name} }">
          <img :src="item.picUrl" alt="">
          <p>{{ item.name }}</p>
        </router-link>
      </li>
    </ul>
    <p v-else>暂无数据</p>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "Music",
  data() {
    return {
      artists: []
    }
  },
  created() {
    axios.get("https://koo-music.vercel.app/artist/list").then(res => {
      this.artists = res.data.artists
      console.log(this.artists)
    })
  }
}
</script>

<!-- index.less -->
<!-- index.scss -->
<!-- index.sass -->
<!-- css预处理器  postcss -->
<style scoped lang="less">
@size: 120px;
@bg: #fab;

.border {
  border: 2px solid #42b983;
}

.music {
  ul {
    display: flex;
    flex-wrap: wrap;
    list-style: none;



    //li:hover{}

    li {
      .border();
      width: 200px;
      background-color: @bg;

      &:hover {
        background-color: #42b983;
      }

      img {
        width: @size;
        height: @size;
        object-fit: cover;
        vertical-align:baseline;
      }
    }
  }
}

/*.music ul li {
  width: 200px;
}
.music ul li img {
  width: 100px;
  height: 100px;
  object-fit: cover;
}
*/
</style>
